import 'package:flutter/material.dart';
import 'package:fzcgx_app/common/adapter_utils.dart';
import 'package:fzcgx_app/common/assets_utils.dart';
import 'package:fzcgx_app/provider/provider_widget.dart';
import 'package:fzcgx_app/router/routes.dart';
import 'package:fzcgx_app/ui/base/base_view_model.dart';
import 'package:fzcgx_app/ui/my/worker/view_model/worker_certificates_view_model.dart';
import 'package:fzcgx_app/ui/widget/custom_appbar_widget.dart';

class WorkerCertificatesPage extends StatefulWidget {
  WorkerCertificatesPage({Key key,this.callback}) : super(key: key);
final Function callback;
  @override
  _WorkerCertificatesPageState createState() => _WorkerCertificatesPageState();
}

class _WorkerCertificatesPageState extends State<WorkerCertificatesPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: CustomAppbar(
        title: '证件上传',
        onTap: (){
          Routes.goBack(context);
          widget.callback();
        },
      ),
      body: SafeArea(
          child: ProviderWidget<WorkerCertificatesViewModel>(
        model: WorkerCertificatesViewModel(),
        onReady: (viewModel) {
          viewModel.requestApi();
        },
        builder: (context, viewModel, child) {
          return viewModel.state == ViewState.Loading
              ? Container()
              : SingleChildScrollView(
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      SizedBox(
                        height: AdapterUtils.getHeight(4),
                      ),
                      Container(
                        height: AdapterUtils.getHeight(38),
                        color: Color(0xffEAF7FE),
                        child: Center(
                          child: Text(
                            '注册填写/上传的信息越全面，客户信任度越高',
                            style: TextStyle(
                              fontSize: AdapterUtils.getSp(13),
                              color: Color(0xff15A1FF),
                              fontWeight: FontWeight.w500,
                            ),
                          ),
                        ),
                      ),
                      Container(
                        margin: EdgeInsets.symmetric(
                            horizontal: AdapterUtils.getWidth(15)),
                        child: _buildLegalPersonCertificateWidget(viewModel),
                      )
                    ],
                  ),
                );
        },
      )),
    );
  }

  Widget _buildLegalPersonCertificateWidget(
      WorkerCertificatesViewModel viewModel) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: <Widget>[
        SizedBox(
          height: AdapterUtils.getHeight(18),
        ),
        Text(
          '本人照片',
          style: TextStyle(
            fontSize: AdapterUtils.getSp(14),
            color: Color(0xff606B79),
            fontWeight: FontWeight.w500,
          ),
        ),
        SizedBox(
          height: AdapterUtils.getHeight(12),
        ),
        InkWell(
          onTap: () {
            viewModel.selectPhoto(context, 1);
          },
          child: Container(
            padding: EdgeInsets.only(bottom: AdapterUtils.getHeight(20)),
            decoration: BoxDecoration(
                border: Border(
                    bottom: BorderSide(color: Color(0xffE8E9ED), width: 1))),
            child: Row(
              children: <Widget>[
                Container(
                  width: AdapterUtils.getWidth(108),
                  height: AdapterUtils.getHeight(108),
                  child: Stack(
                    children: <Widget>[
                      AspectRatio(
                        aspectRatio: 1.0,
                        child: viewModel.model.xingxiangzhao.isEmpty
                            ? Image.asset(
                                AssetsUtils.getAssetsImagesPath('upload.png'))
                            : Image.network(viewModel.model.xingxiangzhao),
                      ),
                    viewModel.model.xingxiangzhao.isEmpty?Positioned(
                          bottom: AdapterUtils.getHeight(37),
                          child: Container(
                            width: AdapterUtils.getWidth(108),
                            alignment: Alignment.center,
                            child: Text(
                              '请上传/拍摄',
                              style: TextStyle(
                                fontSize: AdapterUtils.getSp(12),
                                color: Color(0xff99A2AD),
                                fontWeight: FontWeight.w500,
                              ),
                            ),
                          )):Container()
                    ],
                  ),
                ),
                SizedBox(
                  width: AdapterUtils.getWidth(20),
                ),
                Expanded(
                    child: RichText(
                  text: TextSpan(children: <InlineSpan>[
                    TextSpan(
                      text: '拍摄时确保照片',
                      style: TextStyle(
                        fontSize: AdapterUtils.getSp(12),
                        color: Color(0xff99A2AD),
                        fontWeight: FontWeight.w500,
                      ),
                    ),
                    TextSpan(
                      text: '边框完整，字体清晰， 亮度均匀',
                      style: TextStyle(
                        fontSize: AdapterUtils.getSp(12),
                        color: Color(0xff15A1FF),
                        fontWeight: FontWeight.w500,
                      ),
                    ),
                  ]),
                ))
              ],
            ),
          ),
        ),
        SizedBox(
          height: AdapterUtils.getHeight(24),
        ),
        RichText(
          text: TextSpan(children: <InlineSpan>[
            TextSpan(
              text: '身份证正面照 ',
              style: TextStyle(
                fontSize: AdapterUtils.getSp(14),
                color: Color(0xff606B79),
                fontWeight: FontWeight.w500,
              ),
            ),
            TextSpan(
              text: '*',
              style: TextStyle(
                fontSize: AdapterUtils.getSp(14),
                color: Color(0xffFF1515),
                fontWeight: FontWeight.w500,
              ),
            ),
          ]),
        ),
        SizedBox(
          height: AdapterUtils.getHeight(12),
        ),
        InkWell(
          onTap: () {
            viewModel.selectPhoto(context, 2);
          },
          child: Container(
            padding: EdgeInsets.only(bottom: AdapterUtils.getHeight(20)),
            decoration: BoxDecoration(
                border: Border(
                    bottom: BorderSide(color: Color(0xffE8E9ED), width: 1))),
            child: Row(
              children: <Widget>[
                Container(
                  width: AdapterUtils.getWidth(108),
                  height: AdapterUtils.getHeight(108),
                  child: Stack(
                    children: <Widget>[
                      AspectRatio(
                        aspectRatio: 1.0,
                        child:viewModel.model.shenfenzhengzhengmian.isEmpty
                            ? Image.asset(
                                AssetsUtils.getAssetsImagesPath('upload.png'))
                            : Image.network(viewModel.model.shenfenzhengzhengmian),
                      ),
                    viewModel.model.shenfenzhengzhengmian.isEmpty?  Positioned(
                          bottom: AdapterUtils.getHeight(37),
                          child: Container(
                            width: AdapterUtils.getWidth(108),
                            alignment: Alignment.center,
                            child: Text(
                              '请上传/拍摄',
                              style: TextStyle(
                                fontSize: AdapterUtils.getSp(12),
                                color: Color(0xff99A2AD),
                                fontWeight: FontWeight.w500,
                              ),
                            ),
                          )):Container()
                    ],
                  ),
                ),
                SizedBox(
                  width: AdapterUtils.getWidth(20),
                ),
                Expanded(
                    child: RichText(
                  text: TextSpan(children: <InlineSpan>[
                    TextSpan(
                      text: '拍摄时确保照片',
                      style: TextStyle(
                        fontSize: AdapterUtils.getSp(12),
                        color: Color(0xff99A2AD),
                        fontWeight: FontWeight.w500,
                      ),
                    ),
                    TextSpan(
                      text: '边框完整，字体清晰， 亮度均匀',
                      style: TextStyle(
                        fontSize: AdapterUtils.getSp(12),
                        color: Color(0xff15A1FF),
                        fontWeight: FontWeight.w500,
                      ),
                    ),
                  ]),
                ))
              ],
            ),
          ),
        ),
        SizedBox(
          height: AdapterUtils.getHeight(24),
        ),
        RichText(
          text: TextSpan(children: <InlineSpan>[
            TextSpan(
              text: '身份证反面照 ',
              style: TextStyle(
                fontSize: AdapterUtils.getSp(14),
                color: Color(0xff606B79),
                fontWeight: FontWeight.w500,
              ),
            ),
            TextSpan(
              text: '*',
              style: TextStyle(
                fontSize: AdapterUtils.getSp(14),
                color: Color(0xffFF1515),
                fontWeight: FontWeight.w500,
              ),
            ),
          ]),
        ),
        SizedBox(
          height: AdapterUtils.getHeight(12),
        ),
        InkWell(
          onTap: () {
            viewModel.selectPhoto(context, 3);
          },
          child: Container(
            padding: EdgeInsets.only(bottom: AdapterUtils.getHeight(20)),
            decoration: BoxDecoration(
                border: Border(
                    bottom: BorderSide(color: Color(0xffE8E9ED), width: 1))),
            child: Row(
              children: <Widget>[
                Container(
                  width: AdapterUtils.getWidth(108),
                  height: AdapterUtils.getHeight(108),
                  child: Stack(
                    children: <Widget>[
                      AspectRatio(
                        aspectRatio: 1.0,
                        child: viewModel.model.shenfenzhengfanmian.isEmpty
                            ? Image.asset(
                                AssetsUtils.getAssetsImagesPath('upload.png'))
                            : Image.network(viewModel.model.shenfenzhengfanmian),
                      ),
                    viewModel.model.shenfenzhengfanmian.isEmpty?  Positioned(
                          bottom: AdapterUtils.getHeight(37),
                          child: Container(
                            width: AdapterUtils.getWidth(108),
                            alignment: Alignment.center,
                            child: Text(
                              '请上传/拍摄',
                              style: TextStyle(
                                fontSize: AdapterUtils.getSp(12),
                                color: Color(0xff99A2AD),
                                fontWeight: FontWeight.w500,
                              ),
                            ),
                          )):Container()
                    ],
                  ),
                ),
                SizedBox(
                  width: AdapterUtils.getWidth(20),
                ),
                Expanded(
                    child: RichText(
                  text: TextSpan(children: <InlineSpan>[
                    TextSpan(
                      text: '拍摄时确保照片',
                      style: TextStyle(
                        fontSize: AdapterUtils.getSp(12),
                        color: Color(0xff99A2AD),
                        fontWeight: FontWeight.w500,
                      ),
                    ),
                    TextSpan(
                      text: '边框完整，字体清晰， 亮度均匀',
                      style: TextStyle(
                        fontSize: AdapterUtils.getSp(12),
                        color: Color(0xff15A1FF),
                        fontWeight: FontWeight.w500,
                      ),
                    ),
                  ]),
                ))
              ],
            ),
          ),
        ),
        SizedBox(
          height: AdapterUtils.getHeight(24),
        ),
        Text(
          '毕业证',
          style: TextStyle(
            fontSize: AdapterUtils.getSp(14),
            color: Color(0xff606B79),
            fontWeight: FontWeight.w500,
          ),
        ),
        SizedBox(
          height: AdapterUtils.getHeight(12),
        ),
        InkWell(
          onTap: () {
            viewModel.selectPhoto(context, 4);
          },
          child: Container(
            padding: EdgeInsets.only(bottom: AdapterUtils.getHeight(20)),
            decoration: BoxDecoration(
                border: Border(
                    bottom: BorderSide(color: Color(0xffE8E9ED), width: 1))),
            child: Row(
              children: <Widget>[
                Container(
                  width: AdapterUtils.getWidth(108),
                  height: AdapterUtils.getHeight(108),
                  child: Stack(
                    children: <Widget>[
                      AspectRatio(
                        aspectRatio: 1.0,
                        child: viewModel.model.jiangzhuang.isEmpty
                            ? Image.asset(
                                AssetsUtils.getAssetsImagesPath('upload.png'))
                            : Image.network(viewModel.model.jiangzhuang),
                      ),
                    viewModel.model.jiangzhuang.isEmpty?  Positioned(
                          bottom: AdapterUtils.getHeight(37),
                          child: Container(
                            width: AdapterUtils.getWidth(108),
                            alignment: Alignment.center,
                            child: Text(
                              '请上传/拍摄',
                              style: TextStyle(
                                fontSize: AdapterUtils.getSp(12),
                                color: Color(0xff99A2AD),
                                fontWeight: FontWeight.w500,
                              ),
                            ),
                          )):Container()
                    ],
                  ),
                ),
                SizedBox(
                  width: AdapterUtils.getWidth(20),
                ),
                Expanded(
                    child: RichText(
                  text: TextSpan(children: <InlineSpan>[
                    TextSpan(
                      text: '拍摄时确保照片',
                      style: TextStyle(
                        fontSize: AdapterUtils.getSp(12),
                        color: Color(0xff99A2AD),
                        fontWeight: FontWeight.w500,
                      ),
                    ),
                    TextSpan(
                      text: '边框完整，字体清晰， 亮度均匀',
                      style: TextStyle(
                        fontSize: AdapterUtils.getSp(12),
                        color: Color(0xff15A1FF),
                        fontWeight: FontWeight.w500,
                      ),
                    ),
                  ]),
                ))
              ],
            ),
          ),
        ),
        SizedBox(
          height: AdapterUtils.getHeight(24),
        ),
        Text(
          '奖状照',
          style: TextStyle(
            fontSize: AdapterUtils.getSp(14),
            color: Color(0xff606B79),
            fontWeight: FontWeight.w500,
          ),
        ),
        SizedBox(
          height: AdapterUtils.getHeight(12),
        ),
        InkWell(
          onTap: () {
            viewModel.selectPhoto(context, 5);
          },
          child: Container(
            padding: EdgeInsets.only(bottom: AdapterUtils.getHeight(20)),
            decoration: BoxDecoration(
                border: Border(
                    bottom: BorderSide(color: Color(0xffE8E9ED), width: 1))),
            child: Row(
              children: <Widget>[
                Container(
                  width: AdapterUtils.getWidth(108),
                  height: AdapterUtils.getHeight(108),
                  child: Stack(
                    children: <Widget>[
                      AspectRatio(
                        aspectRatio: 1.0,
                        child: viewModel.model.jiehunzheng.isEmpty
                            ? Image.asset(
                                AssetsUtils.getAssetsImagesPath('upload.png'))
                            : Image.network(viewModel.model.jiehunzheng),
                      ),
                      viewModel.model.jiehunzheng.isEmpty? Positioned(
                          bottom: AdapterUtils.getHeight(37),
                          child: Container(
                            width: AdapterUtils.getWidth(108),
                            alignment: Alignment.center,
                            child: Text(
                              '请上传/拍摄',
                              style: TextStyle(
                                fontSize: AdapterUtils.getSp(12),
                                color: Color(0xff99A2AD),
                                fontWeight: FontWeight.w500,
                              ),
                            ),
                          )):Container
                    ],
                  ),
                ),
                SizedBox(
                  width: AdapterUtils.getWidth(20),
                ),
                Expanded(
                    child: RichText(
                  text: TextSpan(children: <InlineSpan>[
                    TextSpan(
                      text: '拍摄时确保照片',
                      style: TextStyle(
                        fontSize: AdapterUtils.getSp(12),
                        color: Color(0xff99A2AD),
                        fontWeight: FontWeight.w500,
                      ),
                    ),
                    TextSpan(
                      text: '边框完整，字体清晰， 亮度均匀',
                      style: TextStyle(
                        fontSize: AdapterUtils.getSp(12),
                        color: Color(0xff15A1FF),
                        fontWeight: FontWeight.w500,
                      ),
                    ),
                  ]),
                ))
              ],
            ),
          ),
        ),
        SizedBox(
          height: AdapterUtils.getHeight(24),
        ),
        Text(
          '结婚证照',
          style: TextStyle(
            fontSize: AdapterUtils.getSp(14),
            color: Color(0xff606B79),
            fontWeight: FontWeight.w500,
          ),
        ),
        SizedBox(
          height: AdapterUtils.getHeight(12),
        ),
        InkWell(
          onTap: () {
            viewModel.selectPhoto(context, 6);
          },
          child: Container(
            padding: EdgeInsets.only(bottom: AdapterUtils.getHeight(20)),
            decoration: BoxDecoration(
                border: Border(
                    bottom: BorderSide(color: Color(0xffE8E9ED), width: 1))),
            child: Row(
              children: <Widget>[
                Container(
                  width: AdapterUtils.getWidth(108),
                  height: AdapterUtils.getHeight(108),
                  child: Stack(
                    children: <Widget>[
                      AspectRatio(
                        aspectRatio: 1.0,
                        child: viewModel.model.jiashizheng.isEmpty
                            ? Image.asset(
                                AssetsUtils.getAssetsImagesPath('upload.png'))
                            : Image.network(viewModel.model.jiashizheng),
                      ),
                      viewModel.model.jiashizheng.isEmpty? Positioned(
                          bottom: AdapterUtils.getHeight(37),
                          child: Container(
                            width: AdapterUtils.getWidth(108),
                            alignment: Alignment.center,
                            child: Text(
                              '请上传/拍摄',
                              style: TextStyle(
                                fontSize: AdapterUtils.getSp(12),
                                color: Color(0xff99A2AD),
                                fontWeight: FontWeight.w500,
                              ),
                            ),
                          )):Container()
                    ],
                  ),
                ),
        
                SizedBox(
                  width: AdapterUtils.getWidth(20),
                ),
                Expanded(
                    child: RichText(
                  text: TextSpan(children: <InlineSpan>[
                    TextSpan(
                      text: '拍摄时确保照片',
                      style: TextStyle(
                        fontSize: AdapterUtils.getSp(12),
                        color: Color(0xff99A2AD),
                        fontWeight: FontWeight.w500,
                      ),
                    ),
                    TextSpan(
                      text: '边框完整，字体清晰， 亮度均匀',
                      style: TextStyle(
                        fontSize: AdapterUtils.getSp(12),
                        color: Color(0xff15A1FF),
                        fontWeight: FontWeight.w500,
                      ),
                    ),
                  ]),
                ))
              ],
            ),
          ),
        ),
        SizedBox(
          height: AdapterUtils.getHeight(24),
        ),
        Text(
          '驾驶证照',
          style: TextStyle(
            fontSize: AdapterUtils.getSp(14),
            color: Color(0xff606B79),
            fontWeight: FontWeight.w500,
          ),
        ),
        SizedBox(
          height: AdapterUtils.getHeight(12),
        ),
        InkWell(
          onTap: () {
            viewModel.selectPhoto(context, 5);
          },
          child: Container(
            padding: EdgeInsets.only(bottom: AdapterUtils.getHeight(20)),
            decoration: BoxDecoration(
                border: Border(
                    bottom: BorderSide(color: Color(0xffE8E9ED), width: 1))),
            child: Row(
              children: <Widget>[
                Container(
                  width: AdapterUtils.getWidth(108),
                  height: AdapterUtils.getHeight(108),
                  child: Stack(
                    children: <Widget>[
                      AspectRatio(
                        aspectRatio: 1.0,
                        child: viewModel.model.jiehunzheng.isEmpty
                            ? Image.asset(
                                AssetsUtils.getAssetsImagesPath('upload.png'))
                            : Image.network(viewModel.model.jiehunzheng),
                      ),
                      viewModel.model.jiehunzheng.isEmpty? Positioned(
                          bottom: AdapterUtils.getHeight(37),
                          child: Container(
                            width: AdapterUtils.getWidth(108),
                            alignment: Alignment.center,
                            child: Text(
                              '请上传/拍摄',
                              style: TextStyle(
                                fontSize: AdapterUtils.getSp(12),
                                color: Color(0xff99A2AD),
                                fontWeight: FontWeight.w500,
                              ),
                            ),
                          )):Container
                    ],
                  ),
                ),
                SizedBox(
                  width: AdapterUtils.getWidth(20),
                ),
                Expanded(
                    child: RichText(
                  text: TextSpan(children: <InlineSpan>[
                    TextSpan(
                      text: '拍摄时确保照片',
                      style: TextStyle(
                        fontSize: AdapterUtils.getSp(12),
                        color: Color(0xff99A2AD),
                        fontWeight: FontWeight.w500,
                      ),
                    ),
                    TextSpan(
                      text: '边框完整，字体清晰， 亮度均匀',
                      style: TextStyle(
                        fontSize: AdapterUtils.getSp(12),
                        color: Color(0xff15A1FF),
                        fontWeight: FontWeight.w500,
                      ),
                    ),
                  ]),
                ))
              ],
            ),
          ),
        ),

           SizedBox(
            height: AdapterUtils.getHeight(24),
          ),
           Container(
                width: AdapterUtils.screenWidth(),
                height: AdapterUtils.getHeight(50),
                 margin: EdgeInsets.all(15),
                child: FlatButton(
                    onPressed:  () {
                    //  viewModel.onPostApi(context);
                    },
                    disabledColor: Color(0xff15A1FF).withAlpha(80),
                    color: Color(0xff15A1FF),
                    shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.all(Radius.circular(4)),
                    ),
                    child: Text(
                      '保存',
                      style: TextStyle(
                        fontSize: AdapterUtils.getSp(16),
                        color: Colors.white,
                        fontWeight: FontWeight.w500,
                      ),
                    ))),
            SizedBox(
              height: AdapterUtils.getHeight(16),
            )
      ],
    );
  }

}
